<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
		.mini-tabs-header-left .mini-tabs-space2 div{
    		height: 5px;
		}
		html, body{
       		margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    	}
	</style>
</head>
<body>
	<div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%; height:100%;padding: 5px;" plain="false" tabPosition="left" ontabload="tabload" >
	    <sec:authorize url='/call_manage_my_unt_customer.do'>
	    <div title="客户信息" url="call_manage_my_unt_customer.do" refreshOnClick="true" allowResize="false" >
			<input class="mini-hidden" id="call_id"/>
			<input class="mini-hidden" id="call_status"/>
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/orders_init.do'>
	    <div title="订单信息" url="orders_init.do" name="cInfo" refreshOnClick="true" enabled="false">
	    	<input class="mini-hidden" id="customer_id"/>
	    	<input class="mini-hidden" id="customer_name"/>
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/contact_record_init.do'>
	    <div title="联系记录" url="contact_record_init.do" name="cInfo" refreshOnClick="true" enabled="false">
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/customer_call_records_init.do'>
	    <div title="通话记录" url="customer_call_records_init.do" refreshOnClick="true" enabled="false">
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/customer_remind.do'>
	    <div title="客户提醒" url="customer_remind.do" refreshOnClick="true" enabled="false">
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/customer_sms_init.do'>
	    <div title="发送短信" url="customer_sms_init.do" refreshOnClick="true" enabled="false" >
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/customer_health_init.do'>
	    <div title="健康档案" url="customer_health_init.do" refreshOnClick="true" enabled="false">
	    </div>
	    </sec:authorize>
	    <sec:authorize url='/customer_recommend_init.do'>
	    <div title="推荐信息" url="customer_recommend_init.do" refreshOnClick="true" enabled="false">
	    </div>
	    </sec:authorize>
	</div>
	
	<div id="win1" class="mini-window" title="修改任务状态" showModal="false" allowDrag="true"
	 showHeader="true" allowResize="false" showCloseButton="false" style="width: 260px;height: 180px;">
	 	<div id="edit_status_div">
			<input emptyText="请选择任务状态" labelField="true" label="任务状态：" labelStyle="width: 60px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;" id="c_status" textField="keyValue" valueField="keyName" 
	    		url="call_manage_my_unt_status.do?keyType=CALL_HANDLE_STATUS" onvaluechanged="statusValuechanged"/> 
	    	<input labelField="true" label="话务组：" labelStyle="width: 60px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;display: none;" id="transfer_group" textField="name" valueField="id" 
	    		url=""  onvaluechanged="onGroupChanged"/> 
		    <input labelField="true" label="座席：" labelStyle="width: 60px;" class="mini-combobox" style="width:200px;margin-top: 10px;margin-left: 15px;display: none;" id="transfer_seat" textField="name" valueField="id" 
	    		url=""/>
			<div style="text-align:center;padding-bottom: 10px;margin-top: 15px;">
				<a class="mini-button" onclick="editStatusOk" >确定</a>
			</div>
	 	</div>
	 	<div id="disable_edit_div" style="display: none;">
	 		任务已结束……
	 	</div>
	</div>

<script type="text/javascript">
	mini.parse();
	
	var callId = mini.get("call_id");
	var customerId = mini.get("customer_id");
	var customerName = mini.get("customer_name");
	var callStatus = mini.get("call_status");
	var editStatusDiv = $("#edit_status_div");
	var disableEditDiv = $("#disable_edit_div");
// 	var calltraDiv = $("#call_tra_div");
	function SetData(data) {
		 //跨页面传递的数据对象，克隆后才可以安全使用
		 // 获取列表页传过来的任务id
		data = mini.clone(data);
		callId.setValue(data.row.id);
		callStatus.setValue(data.callStatus);
		if(data.callStatus != 0) {
			//显示弹窗
			win1.showAtPos( "right", "bottom" );
		} 
		if(data.callStatus == 25) {
			editStatusDiv.hide();
			disableEditDiv.show();
			disableEditDiv.html("任务已结束……");
		} else if(data.callStatus == 24) {
			editStatusDiv.hide();
			disableEditDiv.show();
			disableEditDiv.html("任务已转移……");
		} else if(data.callStatus == 11) {
			editStatusDiv.hide();
			disableEditDiv.show();
			disableEditDiv.html("任务已终止……");
		}
	}
	
	var tabs = mini.get("tabs1");
	top["win"] = window;
	function setEnable(cId, cName, callTaskId){
	    for(var i=1; i<8; i++) {
	    	tabs.updateTab(i,{enabled:true});
	    }
	    customerId.setValue(cId);
	    customerName.setValue(cName);
	    callId.setValue(callTaskId);
	}
	
	// 将任务id传到客户信息页面（tab内容页面加载完成时激发）
	function tabload(e) {
		var data = {
			id: callId.getValue(), 
			customerId: customerId.getValue(), 
			customerName: customerName.getValue(), 
			callStatus: callStatus.getValue(),
			openType: "deal"					// 任务打开类型（处理打开、弹屏打开）
		}; 
		var iframe = this.getTabIFrameEl(e.tab);
	    iframe.contentWindow.SetData(data);
	}
	
	// 修改任务状态
	var win1 = mini.get("win1");
	var cStatus = mini.get("c_status");
	var tGroup = mini.get("transfer_group");
	var tSeat = mini.get("transfer_seat");
	function statusValuechanged(e) {
		if(e.value == 24) {
			tGroup.load("call_manage_my_unt_group.do");
			tGroup.show();
			tSeat.show();
		} else {
			tGroup.hide();
			tSeat.hide();
		}
	}
	
	function onGroupChanged(e) {
		tSeat.setValue("");
       var url = "call_manage_my_unt_seat.do?groupId=" + e.value;
       tSeat.setUrl(url);
       tSeat.select(0);
	}
	
	function editStatusOk() {
		var statusKey = cStatus.getValue();
		if(statusKey.length > 0) {
			if(statusKey == 24) {
				if(tGroup.getValue().length > 0 && tSeat.getValue().length > 0) {
					mini.confirm("确定修改任务状态？（修改后，该页面将会被关闭！）", "修改任务状态", function (action) {
						if(action == "ok") {
							$.post("call_open_edit_status.do", {id: callId.getValue(), callStatus: callStatus.getValue(), statusKey: statusKey, groupId: tGroup.getValue(), handleUserId: tSeat.getValue()}, function(data){
								if(data.success){
									window.CloseOwnerWindow("editStatus");
								}else{
									mini.alert("修改失败（任务id或类别为空）");
								}
							}, "json");
						}
					});
				} else {
					mini.alert("请选择话务组和座席！");
				}
			} else {
				mini.confirm("确定修改任务状态？（修改后，该页面将会被关闭！）", "修改任务状态", function (action) {
					if(action == "ok") {
						$.post("call_open_edit_status.do", {id: callId.getValue(), callStatus: callStatus.getValue(), statusKey: statusKey}, function(data){
							if(data.success){
								window.CloseOwnerWindow("editStatus");
							}else{
								mini.alert("修改失败（任务id或类别为空）");
							}
						}, "json");
					}
				});
			}
		}else {
			mini.alert("未选择状态");
		}
	}
	
</script>
</body>
</html>